<?php
// +----------------------------------------------------------------------
// | @filename CreateMenuRequest.php
// +----------------------------------------------------------------------
// | @author 落花轻舞问君愁 <mwcx1990@qq.com>
// +----------------------------------------------------------------------
// | @datetime 2021-11-01 21:00:42
// +----------------------------------------------------------------------
// | @Description
// +----------------------------------------------------------------------

namespace Addons\Backend\Http\Requests\Menu;


use Addons\Backend\Http\Requests\BaseRequest;

class CreateMenuRequest extends BaseRequest
{
    public function rules(): array
    {
        return [
            'title' => ['bail', 'required', 'min:2', 'max:30'],
            'pid' => ['bail', 'nullable', 'integer'],
            'hidden' => ['bail', 'required', 'in:0,1'],
            'icon' => ['bail', 'nullable', 'max:40'],
            'redirect' => ['bail', 'nullable', 'max:100'],
            'path' => ['bail', 'required', 'max:100'],
            'name' => ['bail', 'required', 'max:40'],
            'breadcrumb' => ['bail', 'required', 'in:0,1'],
            'roles' => ['bail', 'nullable', 'array'],
            'sort' => ['bail', 'required', 'integer'],
            'no_cache' => ['bail', 'required', 'in:0,1'],
            'affix' => ['bail', 'required', 'in:0,1']
        ];
    }

    public function messages(): array
    {
        return [
            'title.required' => '请输入菜单名称',
            'title.min' => '菜单名称不能少于2位',
            'title.max' => '菜单名称不能大于30位',
            'pid.required' => '请选择父级菜单',
            'pid.integer' => '请选择正确的父级菜单',
            'hidden.required' => '请选择是否在侧边栏是否隐藏',
            'hidden.in' => '请选择是否在侧边栏是否隐藏',
            'icon.max' => 'icon不能大于40位',
            'redirect.max' => '路由重定向不能大于100位',
            'path.required' => '请输入路由路径',
            'path.max' => 'icon不能大于100位',
            'name.required' => '请输入路由名称',
            'name.max' => 'icon不能大于40位',
            'breadcrumb.required' => '请选择是否在面包屑中显示',
            'required.in' => '请选择是否在面包屑中显示',
            'no_cache.required' => "请选择是否<keep-alive>缓存",
            'no_cache.in' => '请选择是否<keep-alive>缓存',
            'affix.required' => "请选择是否在tags-view固定",
            'affix.in' => '请选择是否在tags-view固定',
            'sort.required' => '请输入排序值',
            'sort.integer' => '排序值必须是个数字',
            'roles.array' => '授权角色必须是个数组'
        ];
    }

    public function authorize(): bool
    {
        return true;
    }
}
